import 'package:gold/generated/json/base/json_convert_content.dart';
import 'package:gold/model/withdrawal_record_model.dart';

WithdrawalRecordModel $WithdrawalRecordModelFromJson(Map<String, dynamic> json) {
  final WithdrawalRecordModel withdrawalRecordModel = WithdrawalRecordModel();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    withdrawalRecordModel.id = id;
  }
  final int? userId = jsonConvert.convert<int>(json['user_id']);
  if (userId != null) {
    withdrawalRecordModel.userId = userId;
  }
  final double? amount = jsonConvert.convert<double>(json['amount']);
  if (amount != null) {
    withdrawalRecordModel.amount = amount;
  }
  final String? orderNo = jsonConvert.convert<String>(json['order_no']);
  if (orderNo != null) {
    withdrawalRecordModel.orderNo = orderNo;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    withdrawalRecordModel.status = status;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    withdrawalRecordModel.createdAt = createdAt;
  }
  final String? updatedAt = jsonConvert.convert<String>(json['updated_at']);
  if (updatedAt != null) {
    withdrawalRecordModel.updatedAt = updatedAt;
  }
  return withdrawalRecordModel;
}

Map<String, dynamic> $WithdrawalRecordModelToJson(WithdrawalRecordModel entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['user_id'] = entity.userId;
  data['amount'] = entity.amount;
  data['order_no'] = entity.orderNo;
  data['status'] = entity.status;
  data['created_at'] = entity.createdAt;
  data['updated_at'] = entity.updatedAt;
  return data;
}

extension WithdrawalRecordModelExtension on WithdrawalRecordModel {
  WithdrawalRecordModel copyWith({
    int? id,
    int? userId,
    double? amount,
    String? orderNo,
    int? status,
    String? createdAt,
    String? updatedAt,
  }) {
    return WithdrawalRecordModel()
      ..id = id ?? this.id
      ..userId = userId ?? this.userId
      ..amount = amount ?? this.amount
      ..orderNo = orderNo ?? this.orderNo
      ..status = status ?? this.status
      ..createdAt = createdAt ?? this.createdAt
      ..updatedAt = updatedAt ?? this.updatedAt;
  }
}